package week7;

   
    public abstract class Animal {
        private String name;
        private int id;

        public Animal(String name, int id) {
            this.name = name;
            this.id = id;
        }
        public abstract void eat();
        public abstract void sleep();
        public abstract void introduction() ;

        public String getName() {
            return name;
        }

        public int getId() {
            return id;
        }
    }

    class Cow extends Animal{
        Cow(String name, int id){
            super(name,id);
        }

        @Override
        public void eat() {
            System.out.println( this.getName() + "eat grass");        }

        @Override
        public void sleep() {
            System.out.println(this.getName() + " sleep");
        }

        @Override
        public void introduction() {
            System.out.println("大家好！我是" + "编号为" + this.getId() + "名字为：" + this.getName() +"");
        }
    }

    class Sheep extends Animal{
        Sheep(String name, int id){
            super(name,id);
        }

        @Override
        public void eat() {
            System.out.println(this.getName() + "eat grass");
        }

        @Override
        public void sleep() {
            System.out.println(this.getName() + " sleep");
        }

        @Override
        public void introduction() {
            System.out.println("大家好！我是" + "编号为" + this.getId() + "名字为：" + this.getName() +"");
        }

    }

    class AnimalTest {
        public static void main(String[] args){
    Cow cw = new Cow("香锅肥牛", 6);
    Sheep sp = new Sheep("喜羊羊", 5);

    cw.eat();
    cw.sleep();
    cw.introduction();
    sp.eat();
    sp.sleep();
    sp.introduction();
    }
}

